package com.gexiaobao.pigeon.ui.fragment.mine.pigeon.activity

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.gexiaobao.pigeon.app.base.BaseActivity
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.app.model.bean.PigeonBean
import com.gexiaobao.pigeon.app.model.bean.PigeonFosterBean
import com.gexiaobao.pigeon.databinding.ActivityShedPigeonDetailBinding
import com.gexiaobao.pigeon.ui.adapter.MyPagerAdapter
import com.gexiaobao.pigeon.ui.fragment.mine.pigeon.FragmentShedPigeonBasicInfo
import com.gexiaobao.pigeon.ui.fragment.mine.pigeon.FragmentTrainingRecord
import com.gexiaobao.pigeon.viewmodel.ShedPigeonViewModel

/**
 * @Author      : hxw
 * @Date        : 2024/4/26 10:51
 * @Describe    : 公棚赛鸽-详情
 */
class ActivityShedPigeonDetail : BaseActivity<ShedPigeonViewModel, ActivityShedPigeonDetailBinding>() {

    private var pigeonID: String = ""
    private lateinit var pigeonData: PigeonFosterBean.ListData

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeBar.toolbar.initClose("赛鸽详情") {
            finish()
        }
        pigeonID = intent?.getStringExtra("pigeonId").toString()
        pigeonData = intent?.getSerializableExtra("pigeonData") as PigeonFosterBean.ListData

        initViewPager(pigeonID)
    }

    private fun initViewPager(pigeonID: String) {
        val tabTitles = arrayListOf("基本信息", "训放记录")
        val fragmentList = ArrayList<Fragment>()
        fragmentList.add(FragmentShedPigeonBasicInfo.newInstance(pigeonID, pigeonData.featherColorId))
        fragmentList.add(FragmentTrainingRecord.newInstance(pigeonID))
        mDatabind.viewPager.adapter = MyPagerAdapter(supportFragmentManager, this, fragmentList, tabTitles)
        mDatabind.viewPager.offscreenPageLimit = 2
        mDatabind.tabLayout.setupWithViewPager(mDatabind.viewPager)
    }
}